home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 85 / CD Temático 40 Febrero 2004.iso / DOS / testdisk / src / chgtype.c < prev    next >
Encoding:
C/C++ Source or Header  |  2004-01-02  |  1.9 KB  |  70 lines

  1. /*
  2.  
  3.     File: chgtype.c
  4.  
  5.     Copyright (C) 1998-2004 Christophe GRENIER <grenier@cgsecurity.org>
  6.   
  7.     This software is free software; you can redistribute it and/or modify
  8.     it under the terms of the GNU General Public License as published by
  9.     the Free Software Foundation; either version 2 of the License, or
  10.     (at your option) any later version.
  11.   
  12.     This program is distributed in the hope that it will be useful,
  13.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.     GNU General Public License for more details.
  16.   
  17.     You should have received a copy of the GNU General Public License
  18.     along with this program; if not, write to the Free Software
  19.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20.  
  21.  */
  22. #include <stdarg.h>
  23. #include <stdio.h>
  24. #include <stdlib.h>
  25. #include <string.h>
  26. #include <ctype.h>
  27. #include <unistd.h>    /* geteuid */
  28. #include "types.h"
  29. #include "common.h"
  30. #include "lang.h"
  31. #include "intrface.h"
  32. #include "fnctdsk.h"
  33.  
  34. extern char* nom_os[256];
  35. int change_part_type(const t_param_disk *disk_car,t_diskext *partition)
  36. {
  37.   char response[100];
  38.   int nbr=0;
  39.   int i;
  40.   aff_buffer(BUFFER_RESET,"Q");
  41.   aff_buffer(BUFFER_ADD,"List of partition type\n");
  42.   for(i=0;i<=255;i++)
  43.   {
  44.     if(nom_os[i]!=NULL && strcmp(nom_os[i],"reserved")!=0)
  45.     {
  46.       aff_buffer(BUFFER_ADD,"%02x %-20s ",i,nom_os[i]);
  47.       nbr++;
  48.       if(nbr==3)
  49.       {
  50.     nbr=0;
  51.     aff_buffer(BUFFER_ADD,"\n");
  52.       }
  53.     }
  54.   }
  55.   aff_copy(stdscr);
  56.   wmove(stdscr,4,0);
  57.   aff_part(stdscr,AFF_PART_NONL,disk_car,partition);
  58.   aff_buffer(BUFFER_DISPLAY,"Q",stdscr);
  59.   wmove(stdscr,23,0);
  60.   wdoprintf(stdscr,"New partition type [current %02x] ?",partition->part_type);
  61.   if (get_string(response, sizeof(response), NULL) > 0) {
  62.     int tmp_val = strtol(response, NULL, 16);
  63.     if ((tmp_val > 0) && (tmp_val <= 255) && (is_extended(tmp_val)==0))
  64.       partition->part_type = tmp_val;
  65.   }
  66.   return 0;
  67. }
  68.  
  69.  
  70.